<template>
    <div class="app-container">
        <div class="tcl">
            <el-tabs v-model="activeName">
                <el-tab-pane label="参与投标" name="first">
                    <el-form label-width="100px" size="medium">
                        <el-row type="flex" align="middle" justify="start" :gutter="15">
                            <el-form-item label="项目编号" prop="i_number">
                                <el-input v-model="queryParams.i_number" placeholder="请输入项目编号" clearable
                                    :style="{ width: '100%' }"></el-input>
                            </el-form-item>
                            <el-form-item label="项目名称" prop="h_name">
                                <el-input v-model="queryParams.h_name" placeholder="请输入供应商名称" clearable
                                    :style="{ width: '100%' }"></el-input>
                            </el-form-item>
                            <el-form-item size="medium">
                                <el-button type="primary" @click="handleQuery">查询</el-button>
                                <el-button>重置</el-button>
                            </el-form-item>
                        </el-row>
                    </el-form>
                    <el-table stripe v-loading="loading" :data="resultsData">
                        <el-table-column type="index" label="序号" align="center" width="80" />
                        <el-table-column label="项目编号" align="center" prop="i_number"/>
                        <el-table-column label="供应商id" align="center" prop="hid" />
                        <el-table-column label="供应商名称" align="center" prop="h_name" >

                        </el-table-column>
                        <el-table-column label="公示状态" align="center" prop="gs_state">
                            <template slot-scope="scope">
                                <el-tag size="small" v-if="resultsData[scope.$index].gs_state==0" type="danger">发布</el-tag>
                            </template>
                        </el-table-column>
                        <el-table-column label="公示发布时间" align="center" prop="gs_res_date" >

                        </el-table-column>
                        <el-table-column label="操作" align="center" >
                            <template slot-scope="scope">
                                <router-link :to="'whResultsDatail?iNumber='+scope.row.i_number+'&hid='+scope.row.hid+'&gs_id='+scope.row.gs_id">
                                    <el-button size="small">查看</el-button>
                                </router-link>
                            </template>

                        </el-table-column>
                    </el-table>
                </el-tab-pane>

                <el-tab-pane label="参与未中标" name="midd">
                    <el-form label-width="100px" size="medium">
                        <el-row type="flex" align="middle" justify="start" :gutter="15">
                            <el-form-item label="项目编号" prop="i_number">
                                <el-input v-model="queryParams.i_number" placeholder="请输入项目编号" clearable
                                    :style="{ width: '100%' }"></el-input>
                            </el-form-item>
                            <el-form-item label="项目名称" prop="h_name">
                                <el-input v-model="queryParams.h_name" placeholder="请输入供应商名称" clearable
                                    :style="{ width: '100%' }"></el-input>
                            </el-form-item>
                            <el-form-item size="medium">
                                <el-button type="primary" @click="handleQuery">查询</el-button>
                                <el-button>重置</el-button>
                            </el-form-item>
                        </el-row>
                    </el-form>
                    <el-table stripe v-loading="loading" :data="resultsDataList">
                        <el-table-column type="index" label="序号" align="center" width="80" />
                        <el-table-column label="项目编号" align="center" prop="iNumber"/>
                        <el-table-column label="项目名称" align="center" prop="iName" />
                        <el-table-column label="供应商名称" align="center" prop="hName" >

                        </el-table-column>
                        <el-table-column label="公示发布时间" align="center" prop="gsResDate" >

                        </el-table-column>
                        <el-table-column label="操作" align="center" >
                            <template slot-scope="scope">
                                <router-link :to="'whResultsDatail?iNumber='+scope.row.iNumber+'&hid='+scope.row.hid+'&gs_id='+scope.row.gsId">
                                    <el-button size="small">查看</el-button>
                                </router-link>
                            </template>

                        </el-table-column>
                    </el-table>
                </el-tab-pane>
            </el-tabs>
        </div>
    </div>
</template>

<script>
import {listResults} from "@/api/system/results";
import {getBidCandidateAndSended,getCandidateAndSended} from "@/api/system/purchase";

export default{
    data(){
        return{
            activeName: 'first',
            resultsData: [],
            resultsDataList: [],
             //查询参数
             total: 0,
            //遮罩层
            loading: true,
            queryParams: {
                pageNum: 1,
                pageSize: 10,
                i_number: null,
                h_name: null
            },
            total1: 0,
            queryParams1: {
                pageNum: 1,
                pageSize: 10,
                bidder: 1,
                hName: null,
            },
        }
    },
    created(){
        console.log('组件创建，准备获取数据');
        this.getList();
    },
    methods:{
        getList() {
            this.loading = true;
            console.log(typeof listResults); // 应该输出 'function'
            listResults(this.queryParams).then(response => {
                console.log('Current page1:', this.queryParams.pageNum);
                console.log('Page size1:', this.queryParams.pageSize);
                console.log(response, "API1 响应");
                this.resultsData = response.rows;
                this.total = response.total;
                this.loading = false;
            }).catch(error => {
                console.error('获取数据失败:', error);
                this.loading = false;
            });
            console.log(this.queryParams1.bidder,"llll");
            console.log(this.queryParams1.iNumber,"2222");

            getBidCandidateAndSended(this.queryParams1).then(response => {
                    console.log('API2 响应:', response);
                    if (response.code === 200) {
                        this.resultsDataList = response.data.csTender || [];
                        // 如果需要其他数据
                        // this.supplierResults = response.data.results || [];
                        // this.candidates = response.data.csCandidates || [];
                        // this.tenderInfo = response.data.csTender;
                    }
                    this.loading = false;
                }).catch(error => {
                    console.error('获取数据失败:', error);
                    this.loading = false;
                });

        },
        handleQuery() {
            this.queryParams.pageNum = 1;
            this.getList();
        }
    }
}
</script>
